import React from 'react'
import {TwsReactMarkdownPreview} from 'tws-antd'
import { FormattedMessage } from 'react-intl'
import {getLangFromLocalStorage} from '../../constant/lang-util'

const OnlineLanguageAnswer = ({onlineLanguageQuiz, isStudent, getAnswerFile}) => {
  return (<div>
    <div className='margin-t-3'>
      <h3><FormattedMessage id='作业答案' /></h3>
      <div className='margin-t-2'>
        {isStudent ? <a onClick={getAnswerFile}><FormattedMessage id='作业答案下载' /></a> : ''}
      </div>
      <div className='margin-t-2 mark-down-wrap'>
        <TwsReactMarkdownPreview source={onlineLanguageQuiz.answerDescription} />
      </div>
    </div>
    <div className='margin-t-3'>
      <h3><FormattedMessage id='作业内容' /></h3>
      <div className='margin-t-2 mark-down-wrap'>
        <TwsReactMarkdownPreview source={onlineLanguageQuiz[`description_${getLangFromLocalStorage()}`] || onlineLanguageQuiz.description} />

      </div>
    </div>
  </div>)
}

export default OnlineLanguageAnswer
